USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0005_SUMA_REAJUSTE]    Script Date: 11/28/2011 11:59:44 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0005_SUMA_REAJUSTE]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0005_SUMA_REAJUSTE]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0005_SUMA_REAJUSTE]    Script Date: 11/28/2011 11:59:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[WASP_M0005_SUMA_REAJUSTE]
AS

BEGIN
			SELECT 
				SCCTA, 
				SCOPER,
				SCSUC, 
				SCRUB, 
				J50PCCBNT, 
				J50PCCPS, 
				SUM (SCSDO) reajuste,
				'N' as Securitizado,
				NULL AS sec01ptcta	
			into	dbo.reajuste
			FROM 
				Fsd011 A (NOLOCK), 
				J50PCC B (NOLOCK)
			WHERE 
				--------- REAJUSTE
				((SCRUB BETWEEN '1171002000' AND '1171004500')  OR
				(SCRUB BETWEEN '1371002000' AND '1371004500')  OR
				(SCRUB BETWEEN '1173002000' AND '1173004500')  OR
				(ScRUB BETWEEN '1373002000' AND '1373004500')  OR
				(SCRUB BETWEEN '1175002000' AND '1175008500')  OR
				(SCRUB BETWEEN '1373102000' AND '1373114500')  OR
				(SCRUB BETWEEN '1177002000' AND '1177008500')  OR
				(SCRUB BETWEEN '1373202000' AND '1373214500') )  AND
				SCRUB=J50PCCBNT AND SCSDO<>0 
			GROUP BY SCCTA, SCOPER,	SCSUC,SCRUB,J50PCCPS, J50PCCBNT
END
GO

